<template>
	<view class="detail-page">
		<bnn-loading :loading="isLoading"/>
		<scroll-view scroll-y class="detail-scroll">
			<view class="detail-content">
				<!-- <view class="user-info">
					<view class="user-left">
						<view class="avatar"></view>
						<view class="name"></view>
					</view>
					<view class="user-right">
						<view class="concern"></view>
					</view>
				</view> -->
				<view class="news-title">{{info.title}}</view>
				<view class="news-time">{{info.author}} · {{info.created_at | parseTime}}</view>
				<view v-if="info.video" class="video-box">
					<video
						id="news-video"
						:src="info.video"
						:poster="info.video_img"
						class="news-video"
						autoplay="false"
						loop
						show-mute-btn/>
				</view>
				<view class="news-content">
					<rich-text :nodes="info.content" class="rich-text"/>
				</view>
				<view class="h-line"></view>
				<!-- <view class="disclaimer">此内究不代表搜量网观点，仅供参考，不构成投资建议。投资者据此操作，风险自担。</view> -->
				<view class="disclaimer">搜量网部分图文转载于网络，仅供学习、参考、介绍及报道时事新闻所用。搜量网不拥有版权，版权归版权持有人所有，如有版权方请联系我们删除！</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {getArticleView} from '@/api/addons.js'
	import {getRichText} from '@/utils/index.js'
	import BnnLoading from '@/components/bnn-ui/loading/index.vue'
	
	export default {
		components: {BnnLoading},
		data() {
			return {
				info: {},
				isLoading: true
			}
		},
		onLoad(option) {
			this.context = uni.createVideoContext("news-video", this)
			this.getArticleDetail(option.id)
		},
		methods: {
			getArticleDetail (id) {
				getArticleView({id}).then(res => {
					res.data.content = getRichText(res.data.content)
					this.info = res.data
					
					setTimeout(() => {
						this.isLoading = false
					}, 200)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.detail-page{
		background: #fff;
		.detail-scroll{
			/* #ifdef APP-PLUS */
			height: 100vh;
			/* #endif */
			
			/* #ifndef APP-PLUS */
			height: calc(100vh - var(--window-top));
			/* #endif */
		}
		.detail-content{
			padding: 20rpx 40rpx;
		}
		.news-title{
			font-size: 40rpx;
			font-weight: bold;
		}
		.video-box{
			padding: 20rpx 0 20rpx;
			.news-video{
				width: 100%;
			}
		}
		.news-content{
			padding: 20rpx 0 50rpx;
			.rich-text{
				font-size: 32rpx;
				line-height: 1.6;
			}
		}
		.news-time{
			color: #999;
			padding: 40rpx 0;
			text-align: left;
		}
		.disclaimer{
			color: #999;
			padding: 20rpx 0;
			font-size: 24rpx;
		}
	}
</style>
